Skip to content

bosch_shc: add child lock switch entities - #181423

Open
mosandlt wants to merge 2 commits into
home-assistant:devfrom
mosandlt:bosch-shc-child-lock
Open

bosch_shc: add child lock switch entities#181423
mosandlt wants to merge 2 commits into
home-assistant:devfrom
mosandlt:bosch-shc-child-lock

Conversation

@mosandlt

@mosandlt mosandlt commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Proposed change

None of the devices that expose Bosch's child-lock feature had a way to control it from Home Assistant — switch.py never wired up the ChildProtection service (bool childLockActive) or the thermostat-service child lock (ThermostatService.State enum).

boschshcpy already models both forms behind a uniform child_lock property/setter (bool getter+setter on ChildProtection-mixed devices, enum getter / bool setter on thermostat-family devices), so this just wires them into the existing generic SHCSwitch entity with two new SWITCH_TYPES entries:

  • child_lock (bool on_value=True) for: micromodule shutters/blinds/light-attached/relays/impulse-relays/dimmers, and BSM light switches.
  • child_lock_thermostat (on_value=ThermostatService.State.ON) for: thermostats, room thermostats, wall thermostats.

Both share the same translation_key/icon (child_lock, mdi:lock). Also added a unique_id_suffix param to SHCSwitch.__init__ (mirroring the existing SHCRoutingSwitch pattern) so a device that already has a primary switch entity (e.g. a BSM light switch) doesn't collide unique_ids with its new child-lock entity.

No dependency bump needed — boschshcpy 0.6.4 (already pinned) has had this child_lock property since long before this version.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue:
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

🤖 Generated with Claude Code

https://claude.ai/code/session_01W1XR86oNP5B49zG5obz7Cw

Devices exposing the ChildProtection service (micromodule shutters/
blinds/light-attached/relays/impulse-relays/dimmers, BSM light
switches) or the thermostat-service child lock (thermostats, room
thermostats, wall thermostats) had no way to control child lock from
Home Assistant. boschshcpy already models both forms (bool
childLockActive vs. a ThermostatService.State enum) via a uniform
child_lock property/setter, so this wires them into the existing
generic SHCSwitch entity with two SWITCH_TYPES entries.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W1XR86oNP5B49zG5obz7Cw
@home-assistant

home-assistant Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Hey there @tschamm, mind taking a look at this pull request as it has been labeled with an integration (bosch_shc) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of bosch_shc can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign bosch_shc Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

User-facing documentation and coverage of the BSM unique-ID collision scenario are missing.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds Bosch SHC child-lock switch entities for thermostats, relays, dimmers, blinds, shutters, and light switches.

Changes:

  • Adds Boolean and thermostat-enum child-lock switches.
  • Prevents unique-ID collisions using a suffix.
  • Adds translations, icons, fixtures, and tests.
File summaries
File Description
homeassistant/components/bosch_shc/switch.py Registers and controls child-lock switches.
homeassistant/components/bosch_shc/strings.json Adds the child-lock entity name.
homeassistant/components/bosch_shc/icons.json Adds the child-lock icon.
tests/components/bosch_shc/conftest.py Adds device doubles and bucket fixtures.
tests/components/bosch_shc/test_switch.py Tests thermostat and relay child locks.
Review details

Suppressed comments (1)

homeassistant/components/bosch_shc/switch.py:206

  • Add a BSM-specific test that verifies the existing light switch and new child-lock switch register with distinct unique IDs. The suffix was introduced specifically to prevent this collision, but the current tests only instantiate devices that create one switch, so a regression would not be detected.
            *session.device_helper.light_switches_bsm,
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

for switch in session.device_helper.camera_360
)

entities.extend(
Per Copilot review on home-assistant#181423: the existing tests only covered devices
that get a single switch entity, so a unique_id collision between a
BSM light switch's primary switch and its new child-lock switch
wouldn't have been caught.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W1XR86oNP5B49zG5obz7Cw
Copilot AI review requested due to automatic review settings September 6, 2026 06:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the pinned library APIs and includes representative coverage for both child-lock models and ID collisions.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants